//
//  main.m
//  debug-objc
//
//  Created by suchavision on 1/24/17.
//
//

#import <Foundation/Foundation.h>
#import "objc-runtime.h"
#import "XXObject.h"
#import "YYObject.h"
#import <malloc/malloc.h>
#import "Person.h"
//#import "objc-runtime-new.h"

NSString *binaryWithInteger(NSUInteger decInt){
	NSString * string = @"";
	NSUInteger x = decInt;
	while (x > 0) {
		string = [[NSString stringWithFormat:@"%lu",x&1] stringByAppendingString:string];
		x = x >> 1;
	}
	return string;
}

typedef struct{
	char name[21];
	char age;
}CustomStruct;

typedef CustomStruct *  CustomStructPoint;


struct YTYTest {
    int a;
    int b;
    NSString * str;
};

int main(int argc, const char * argv[]) {
	@autoreleasepool {
		//		struct objc_object *object = (__bridge struct objc_object *)([NSObject new]);
		//		NSLog(@"%@",binaryWithInteger(object->isa));
		//
		//		NSLog(@"%@",binaryWithInteger((uintptr_t)[NSObject class]));
		//
		//		NSLog(@"Hello, World!");
		
		//		Class cls = [XXObject class];
		//		XXObject * xx = [XXObject new];
		//		__unused SEL sel = @selector(undefined_hello_method);
		//		__unused IMP cache_imp = imp_implementationWithBlock(^(){
		//			NSLog(@"cache hello");
		//		});
		//		[xx hello];
		//		[xx hello];
		//		NSLog(@"%p", cls);
		/*
		 CustomStructPoint stu = (CustomStructPoint)malloc(sizeof(CustomStruct));
		 stu->age = 10;
		 strcpy(stu->name, "12das");
		 printf("stack address %p\n",&stu);//堆上内存地址
		 printf("shed address %p\n",stu);//栈上内存地址
		 free(stu);
		 
		 XXObject * obj = [XXObject new];
		 XXObject * obj1 = [obj retain];
		 XXObject * obj2 = [obj1 retain];
		 struct objc_object * obj_obj = (__bridge struct objc_object *)obj;
		 NSLog(@"%@",binaryWithInteger((long)(obj_obj->isa)));
		 NSLog(@"%@",binaryWithInteger((uintptr_t)[XXObject class]));
		 //		struct objc_class* objcClass = (__bridge struct objc_class*)[XXObject class];
		 //		class_rw_t *objRwT = obj->
		 for (NSInteger i = 0; i < 10000000000; i++) {
		 [obj retain];
		 }
		 */
//        XXObject *objc = [[XXObject alloc] init];
//        YYObject * objc1 = [YYObject new];
//        long size = malloc_size(objc);
//		NSLog(@"");
//		NSString * string = @"YTY";
//
//		NSMutableArray * temp = [NSMutableArray array];
//		[temp addObject:string];
//		[string stringByAppendingString:@"菜逼"];
//		for (NSInteger i = 0 ; i < 1000000; i ++) {
//			id objc = [[NSObject alloc] init];
//		}
//        printf("%ld %ld\n",size,sixzeof((objc)));
        
        int a = 1 << 0;
        char b = ~a;
        NSLog(@"%d,%d",a,b);
        
      YTYTest test = {
            10,
            20,
            @"123"
        };
        
        int *s =&a;
        NSLog(@"%p",&test);
        
	}
	return 0;
}

